import request from '@/utils/http.js'
const DEBUGGER = true

/**
 * 通过卡号获取用户积分
 */
export function getBalanceByKey(cardNo) {
  // if(DEBUGGER){
  //     return new Promise((reslove, reject) => {
  //         let ret = '{"msg":"操作成功","code":0,"data":{"cardNo":"10000002","integral":"10"}}';
  //         reslove(JSON.parse(ret));
  //     })
  // }
  return request.post('/integral/cart/getBalanceByKey/' + cardNo, {})
}
/**
 * 积分收入记录
 */
export function incomePage(data) {
  if (DEBUGGER) {
    return new Promise((reslove, reject) => {
      const ret = '{"msg":"操作成功","code":0,"data":{"records":[{"cardNo":"10000002","integral":"10","mktName":"积分调整","time":"2021-03-19"}],"total":1,"size":15,"current":1,"searchCount":true,"pages":1}}'
      reslove(JSON.parse(ret))
    })
  }
  return request.post('/integral/log/in/page', data)
}
/**
 * 积分支出记录
 */
export function expenditurePage(data) {
  if (DEBUGGER) {
    return new Promise((reslove, reject) => {
      const ret = '{"msg":"操作成功","code":0,"data":{"records":[{"cdmno":"90000002","cdlzy":"64","jf":"-20","stcname":"积分兑换券","mfcode":null,"mfcname":"积分兑换券","cdlmkt":"C001","csjhtime":"2020-08-05"},{"cdmno":"90000002","cdlzy":"64","jf":"-1","stcname":"积分兑换券","mfcode":null,"mfcname":"积分兑换券","cdlmkt":"C001","csjhtime":"2020-08-05"},{"cdmno":"90000002","cdlzy":"64","jf":"-1","stcname":"积分兑换券","mfcode":null,"mfcname":"积分兑换券","cdlmkt":"C001","csjhtime":"2020-08-05"},{"cdmno":"90000002","cdlzy":"64","jf":"-1","stcname":"积分兑换券","mfcode":null,"mfcname":"积分兑换券","cdlmkt":"C001","csjhtime":"2020-08-05"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-05-27"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-18"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-09"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-04-09"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-03-31"},{"cdmno":"90000002","cdlzy":"23","jf":"-1","stcname":"返利扣积分","mfcode":null,"mfcname":"返利扣积分","cdlmkt":"201","csjhtime":"2020-03-31"}],"total":43,"size":15,"current":1,"searchCount":true,"pages":3}}'
      reslove(JSON.parse(ret))
    })
  }
  return request.post('/integral/log/out/page', data)
}
/**
 * 查询储值卡列表
 */
export function valueCardList(data) {
  if (DEBUGGER) {
    return new Promise((reslove, reject) => {
      const ret = '{"msg":"操作成功","code":0,"data":[{"cmid":"1","cmthemename":"线上卡","cmthemeimage":null,"cmtermofvaliditystart":"2020-09-01 00:00:00","cmtermofvalidityend":"2029-09-30 00:00:00","cminstructionsforuse":null,"cmstatus":"Y","cmdatetime":"2020-10-10 12:54:20","cmlrr":null,"cardtype":"4","kshd":"20041451","jshd":"20041451","cfvvalue":"500"}]}'
      reslove(JSON.parse(ret))
    })
  }
  return request.post('/value/card/list', data)
}
/**
 * 查询会员储值卡列表
 */
export function valueCardUserList(data) {
  return request.post('/value/card/user/list', data)
}
/**
 * 购买储值卡
 */
export function valueCardBuy(data) {
  return request.post('/value/card/buy', data)
}
/**
 * 储值卡充值
 */
export function valueCardRecharge(data) {
  return request.post('/value/card/recharge', data)
}
/**
 * 储值卡绑定
 */
export function valueCardBind(data) {
  return request.post('/value/card/bind', data)
}
/**
 * 储值卡转赠
 */
export function valueCardGiven(data) {
  return request.post('/value/card/given', data)
}
/**
 * 储值卡转赠状态
 */
export function valueCardGivenStatus(data) {
  return request.post('/value/card/given/status', data)
}
